package com.nowcoder.community.entity;


import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;

/**
 * @author 花木凋零成兰
 * @date 2024/3/4 20:16
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Document(indexName = "discusspost")    // 与Elasticsearch关联 设置索引 注意不能出现大写字母
public class DiscussPost {

    @Id // 与ES索引对应字段
    private int id;

    @Field(type = FieldType.Integer)    // type字段类型
    private int userId;

    /**
     * analyzer时候的解析器   ik_max_word 尽可能的拆分
     * searchAnalyzer搜索时候的解析器   ik_smart 灵活的拆分
     */
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String title;

    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String content;

    // 0-普通  1-置顶
    @Field(type = FieldType.Integer)
    private int type;

    // 0-正常 1-精华 2-拉黑
    @Field(type = FieldType.Integer)
    private int status;

    @Field(type = FieldType.Date)
    private Date createTime;

    @Field(type = FieldType.Integer)
    private int commentCount;

    @Field(type = FieldType.Double)
    private double score;

}
